package com.grape.idempotency.controller;

import com.grape.idempotency.annocation.ExtApiIdempotent;
import com.grape.idempotency.annocation.ExtApiToken;
import com.grape.idempotency.util.ConstantUtils;
import com.grape.idempotency.util.RedisToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class OrderController {

	@Autowired
	private RedisToken redisToken;

	/**
	 * 从redis中获取Token
	 * @return
	 */
	@RequestMapping("/redisToken")
	@ExtApiToken
	public String RedisToken() {
		return redisToken.getToken();
	}

	@RequestMapping(value = "/addOrderExtApiIdempotent", produces = "application/json; charset=utf-8")
	@ExtApiIdempotent(type = ConstantUtils.EXTAPIHEAD)
	public String addOrderExtApiIdempotent() {
		int result = 1;
		return result > 0 ? "添加成功" : "添加失败" + "";
	}

}